/*
ID: ning yusui
PROG: sort3
LANG: C++
*/
#include <fstream>
#include <cstring>
#include <algorithm>

using namespace std;

int main ()
{
    ifstream fin("sort3.in");
    ofstream fout("sort3.out");
    int n,i,j,k,ans=0,data[1000],data_sorted[1000],cnt[3][3]={};
    fin>>n;
	for(i=0; i<n; i++)
	{
		fin>>data[i];
		data[i]--;
	}
	memcpy(data_sorted,data,sizeof(data));
	sort(data_sorted,data_sorted+n);
	for(i=0; i<n; i++)
	{
		cnt[data_sorted[i]][data[i]]++;
	}
	for(i=0; i<3; i++)
	{
		for(j=i+1; j<3; j++)
		{
			k=min(cnt[i][j],cnt[j][i]);
			cnt[i][j]-=k;
			cnt[j][i]-=k;
			ans+=k;
		}
	}
	ans+=2*(cnt[0][1]+cnt[0][2]);
	fout<<ans<<'\n';
    return 0;
}

//YOUR PROGRAM ('sort3') WORKED FIRST TIME!  That's fantastic
//-- and a rare thing.  Please accept these special automated
//congratulations.

